import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../layout'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/',
    component: Layout,
    children: [
      {
        path: '',
        name: 'Home',
        component: () => import('../views/Home.vue'),
        meta: { index: 0, title: 'TodoList' }
      },
      {
        path: 'about',
        name: 'About',
        component: () => import('../views/About.vue')
      },
      {
        path: 'todo',
        name: 'TodoList',
        component: () => import('../views/TodoList'),
        meta: { index: 1, title: 'TodoList' }
      },
      {
        path: 'todo/add',
        name: 'AddTodo',
        component: () => import('../views/TodoList/add.vue'),
        meta: { index: 2, title: '新建计划' }
      },
      {
        path: 'todo/edit',
        name: 'EditTodo',
        component: () => import('../views/TodoList/edit.vue'),
        meta: { index: 2, title: '修改计划' }
      }
    ]
  }
]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes
})

export default router
